<style lang="less" scoped>
.pageview {
    height: 100%;
    background-color: #f1f1f1;
    overflow-y: auto;
    padding-bottom: 80px;
    box-sizing: border-box;
    .comphead {
        position: fixed;
        width: 100%;
        height: 0.44rem;
        top: 0;
        left: 0;
        z-index: 3000;
    }
}
</style>
<template>
    <div class="pageview workbench">
        <CompHead class="comphead" />
        <CompFlodbox :fdata="data" />
        <CompFooter @onReject="clickShowModel" @onResovle="onResovle" />
        <ModelReject v-model="showModel" @onOk="onOk" />
    </div>
</template>
<script>
import CompHead from "./comp/head";
import CompFooter from "./comp/foooter";
import CompFlodbox from "./comp/foldbox";
import ModelReject from "@/components/modelReject";

import {
    getEmployeeOvervier,
    auditEmployee
} from "@/api";

export default {
    data() {
        return {
            showModel: false,
            data: {},
        };
    },
    components: {
        CompHead,
        CompFooter,
        CompFlodbox,
        ModelReject
    },
    methods: {
        // 基本信息
        getOverview () {
            var query = this.$route.query || {};
            getEmployeeOvervier({
                id: query.id
            }).then(res => {
                if (res.code == 1) {
                    var data = res.data;
                    this.data = data;
                }
            });
        },


        // 点击驳回 需要弹窗写理由
        clickShowModel() {
            this.showModel = true;
        },

        // 确认驳回
        onOk(msg) {
            var query = this.$route.query || {};
            var data = {
                id: [query.id],
                type: 2,
                reject_reason: msg
            };
            auditEmployee(data).then(res => {
                if (res.code == 1) {
                    this.$toast("员工已驳回");
                    setTimeout(() => {
                        this.$router.back(-1);
                    }, 500);
                } else {
                    this.$toast(res.msg);
                }
            });
        },

        // 点击确定
        onResovle() {
            var query = this.$route.query || {};
            var data = {
                id: [query.id],
                type: 1,
                reject: ""
            };
            auditEmployee(data).then(res => {
                if (res.code == 1) {
                    this.$toast("审核通过");
                    setTimeout(() => {
                        this.$router.back(-1);
                    }, 500);
                } else {
                    this.$toast(res.msg);
                }
            });
        }
    },
    mounted() {
        this.getOverview();
    }
};
</script>
